import * as express from "express";
import * as logger  from "morgan";
import * as path from "path";
import * as cookieParser from "cookie-parser";
import * as bodyParser from "body-parser";
const app = express();



app.set("views", path.join(__dirname,"views"));
app.set("view engine","pug");

app.all("*", function(req, res, next) {
  res.header("Access-Control-Allow-Origin", "*");
  res.header("Access-Control-Allow-Methods", "PUT, GET, POST, DELETE, OPTIONS");
  res.header("Access-Control-Allow-Headers", "X-Requested-With");
  res.header("Access-Control-Allow-Headers", "Content-Type");
  next();
});

app.use(logger("dev"));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(cookieParser());
app.use("/public", express.static(path.join(__dirname, "public")));
app.get( "/" , function( res , req )  {
    req.render("index",{
      "titls_tag":["学习","主页","帮助","关于"]
    });
});

app.listen(3000,function() {
      console.log("启动了服务器");
});